package com.qi.services.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qi.exception.ServerException;
import com.qi.mapper.TypeMapper;
import com.qi.pojo.entity.Type;
import com.qi.services.ITypeService;
import org.springframework.stereotype.Service;

@Service
public class TypeServiceImpl extends ServiceImpl<TypeMapper, Type> implements ITypeService {
    @Override
    public void add(String name) {
        if (StrUtil.isBlank(name)) {
            throw new ServerException("类型名称不能为空");
        }
        // 构造类型对象
        Type type = new Type();
        type.setName(name);
        this.save(type);
    }
}
